package com.ymatou.iapi.coupon.compare;

import java.io.File;
import java.util.Arrays;

import org.json.JSONArray;

import com.ymatou.iapi.coupon.compare.comparebean.CheckUseCouponResp;
import com.ymatou.iapi.coupon.compare.comparebean.CouponRecommandResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetAllSellerBatchInfoResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetBatchInfoResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetConversionBatchResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetCouponInfoResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetProductAvailablePlatformCouponNumResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetProductAvailablePlatformCouponResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetUserCouponInfoByBatchResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetUserCouponQuantityByBatchResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetUserExpiringAmountResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetUserUsableCouponQuantityResp;
import com.ymatou.iapi.coupon.compare.comparebean.GetValidBatchesBySellerResp;
import com.ymatou.iapi.coupon.compare.comparebean.PagingGetUserCouponsResp;
import com.ymt.core.tool.Logger;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.compare.CompareManager;
import com.ymttest.utils.compare.StartCompare;

public class MainCompare {
	public final static String couponFolder = System.getProperty("user.dir") + File.separator + "resource" + File.separator
			+ "CompareData" + File.separator + "coupon" + File.separator;
	
	
	@StartCompare(isrun=true)
	public static void compareGetCouponListByCode() {
		String paramsFilePath = couponFolder + "couponCode.txt";
		CompareManager.compareApiCall(paramsFilePath,
										true,
										x->MapUtil.hashMap("CouponCodes", new JSONArray(Arrays.asList(x[0]))), 
										CouponCompareAPI.GetCouponListByCodeAPI, 
										CouponCompareAPI.old_GetCouponListByCodeAPI, 
										GetCouponInfoResp.class,
										"data");
		
	}
	
	public static void compareGetBatchInfos() {
		String paramsFilePath = couponFolder + "batchCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										false,
										x->MapUtil.hashMap("BatchCodes", new JSONArray(Arrays.asList(x[0]))), 
										CouponCompareAPI.GetBatchInfosAPI, 
										CouponCompareAPI.old_GetBatchInfosAPI, 
										GetBatchInfoResp.class,
										"data");
		
	}
	
	public static void compareGetUserCouponQuantityByBatch() {
		String paramsFilePath = couponFolder + "userId_batchId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("UserId",x[0],"BatchIds", new JSONArray(Arrays.asList(x[1]))), 
										CouponCompareAPI.GetUserCouponQuantityByBatchAPI, 
										CouponCompareAPI.old_GetUserCouponQuantityByBatchAPI, 
										GetUserCouponQuantityByBatchResp.class,
										"data");
		
	}
	
	public static void compareGetUserUsableCouponQuantity() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("UserId",x[0]), 
										CouponCompareAPI.GetUserUsableCouponQuantityAPI,
										CouponCompareAPI.old_GetUserUsableCouponQuantityAPI, 
										GetUserUsableCouponQuantityResp.class,
										"data");
		
	}
	
	public static void compareGetProductAvailablePlatformCouponNum() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("userId",x[0],"userType",1,"productCode","123",
													"platformId",1,"sellerId",12312,"categoryIds",new JSONArray(Arrays.asList(1,2,3)),
																"countryId",1,"isPsp",false), 
										CouponCompareAPI.GetProductAvailablePlatformCouponNumAPI,
										CouponCompareAPI.old_GetProductAvailablePlatformCouponNumAPI, 
										GetProductAvailablePlatformCouponNumResp.class,
										"data");
		
	}
		
	public static void compareGetProductAvailablePlatformCouponList() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										false,
										x->MapUtil.hashMap("userId",x[0],"userType",1,"productCode","123",
												"platformId",1,"sellerId",12312,"categoryIds",new JSONArray(Arrays.asList(1,2,3)),
															"countryId",1,"isPsp",false), 
										CouponCompareAPI.GetProductAvailablePlatformCouponListAPI,
										CouponCompareAPI.old_GetProductAvailablePlatformCouponListAPI, 
										GetProductAvailablePlatformCouponResp.class,
										"data");
		
	}

	public static void compareGetConversionBatch() {
		String paramsFilePath = couponFolder + "conversionCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("conversionCode",x[0]), 
										CouponCompareAPI.GetConversionBatchAPI,
										CouponCompareAPI.old_GetConversionBatchAPI, 
										GetConversionBatchResp.class,
										"data");
		
	}

	public static void compareGetUserCouponInfosByBatch() {
		String paramsFilePath = couponFolder + "userId_batchCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("UserId",x[0],"BatchCode",x[1]), 
										CouponCompareAPI.GetUserCouponInfosByBatchAPI,
										CouponCompareAPI.old_GetUserCouponInfosByBatchAPI, 
										GetUserCouponInfoByBatchResp.class,
										"data");
		
	}
	
	public static void compareGetAllSellerBatchInfos() {
		String paramsFilePath = couponFolder + "empty.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										false,
										x->MapUtil.hashMap(), 
										CouponCompareAPI.GetAllSellerBatchInfosAPI,
										CouponCompareAPI.old_GetAllSellerBatchInfosAPI, 
										GetAllSellerBatchInfoResp.class,
										"data");
		
	}
	
	
	public static void compareGetValidBatchesBySeller() {
		String paramsFilePath = couponFolder + "sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("SellerIds",new JSONArray(Arrays.asList(x[0])),"isOpenNoThreshold",true), 
										CouponCompareAPI.GetValidBatchesBySellerAPI,
										CouponCompareAPI.old_GetValidBatchesBySellerAPI, 
										GetValidBatchesBySellerResp.class,
										"data");
		
	}
	
	
	public static void compareGetUserExpiringAmount() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("userId",x[0]), 
										CouponCompareAPI.GetUserExpiringAmountAPI,
										CouponCompareAPI.old_GetUserExpiringAmountAPI, 
										GetUserExpiringAmountResp.class,
										"data");
		
	}
	
	public static void compareGetPagingUserCouponList() {
		String paramsFilePath = couponFolder + "userId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										false,
										x->MapUtil.hashMap("BuyerId",x[0],"CreaterType",0,"CouponType",2,"PageIndex",1,"PageSize",5000), 
										CouponCompareAPI.GetPagingUserCouponListAPI,
										CouponCompareAPI.old_GetPagingUserCouponListAPI, 
										PagingGetUserCouponsResp.class,
										"data");
		
	}
	
	
	public static void compareChooseCouponAuto() {
		String paramsFilePath = couponFolder + "userId_sellerId.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										true,
										x->MapUtil.hashMap("ShoppingInfo->BuyerInfo->BuyerId",x[0],
														  "ShoppingInfo->SellerOrderInfos[0]->SellerId",x[1]), 
										CouponCompareAPI.old_ChooseCouponAutoAPI,
										CouponCompareAPI.ChooseCouponAutoAPI, 
										CouponRecommandResp.class,
										"data");
		
	}
	
	public static void compareCheckCoupons() {
		String paramsFilePath = couponFolder + "userId_sellerId_couponCode.txt";
		CompareManager.compareApiCall(paramsFilePath, 
										false,
										x->MapUtil.hashMap("ShoppingInfo->BuyerInfo->BuyerId",x[0],
														  "ShoppingInfo->SellerOrderInfos[0]->SellerId",x[1],
														  "ShoppingInfo->SellerOrderInfos[0]->CouponCode",x[2]), 
										CouponCompareAPI.old_CheckCouponsAPI,
										CouponCompareAPI.CheckCouponsAPI, 
										CheckUseCouponResp.class,
										"data");
		
	}
	
	
	public static void main(String args[]){
		Logger.setDebug(false);
		
		compareGetCouponListByCode();
		//RunManager.runCompareTask(MainCompare.class);
		
		
		
		
		System.out.println("finish");
		
		
		
		
		
		
		
		
		
	/*	
		
		List<Consumer> a= new ArrayList<>();
		for (int i=1;i<a.size();i++){
			a.get(i).accept();
		}
		
		compareGetCouponListByCode();
		
		
		String num="14";
		if (args.length>0){
			num = args[0];
		}
		
		System.out.println(num);
		
		if (num.equals("1")){
			compareGetCouponListByCode();
			
		}else if (num.equals("2")){
			compareGetBatchInfos();
			
		}else if (num.equals("3")){
			compareGetUserCouponQuantityByBatch();
			
		}else if (num.equals("4")){
			compareGetUserUsableCouponQuantity();
			
		}else if (num.equals("5")){
			compareGetProductAvailablePlatformCouponNum();
			
		}else if (num.equals("6")){
			compareGetProductAvailablePlatformCouponList();
			
		}else if (num.equals("7")){
			compareGetConversionBatch();
			
		}else if (num.equals("8")){
			compareGetUserCouponInfosByBatch();
			
		}else if (num.equals("9")){
			compareGetAllSellerBatchInfos();
			
		}else if (num.equals("10")){
			compareGetValidBatchesBySeller();
			
		}else if (num.equals("11")){
			compareGetUserExpiringAmount();
			
		}else if (num.equals("12")){
			compareGetPagingUserCouponList();
			
		}else if (num.equals("13")){
			compareChooseCouponAuto();
			
		}else if (num.equals("14")){
			compareCheckCoupons();
		}
		
		
		
		*/
		
		
		
	
		
		
		
	}
	
	
}
